package com.longshine.arthmetic;

import java.awt.Color;



public class ColorNode extends Node{

	public final static boolean RED = true;
	public final static boolean BLACK = false;
	public boolean color;
	
	public boolean isRad(){
		return color == RED;
	}
	public ColorNode(int weight) {
		super(weight);
		color = RED;
	}
	public ColorNode(int weight,boolean color){
		super(weight);
		this.color = color;
	}
	public ColorNode getParent(){
		return (ColorNode)this.parent;
	}
	public ColorNode getLeft(){
		return (ColorNode)left;
	}
	public ColorNode getRight(){
		return (ColorNode)right;
	}
	public ColorNode getBrother(){
		if(this.getParent()==null){
			return null;
		}
		if(this.getParent().left != this){
			return (ColorNode)this.getParent().left;
		}
		else{
			return (ColorNode)this.getParent().right;
		}
	}
	@Override
	public void beforeDraw() {
		rgb = color==BLACK?Color.BLACK:Color.RED;
	}
	public String toString(){
		return "["+super.toString()+","+(color?"r":"b")+"]";
	}

}
